package com.lanou.beautifulwardrobe.activity;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageButton;
import android.widget.TextView;

import com.lanou.beautifulwardrobe.R;

/**
 * Created by dllo on 15/11/6.
 */
public class WebActivity extends Activity {
    private WebView webView;
    private ImageButton webBack;
    private TextView webTitle;
    private String url;
    private String title;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_webview);
        this.url = getIntent().getStringExtra("url");
        this.title = getIntent().getStringExtra("title");
        initView();
        initData();
    }

    private void initView() {
        webView = (WebView) findViewById(R.id.webView);
        webBack = (ImageButton) findViewById(R.id.webBack);
        webTitle = (TextView) findViewById(R.id.webTitle);
    }

    private void initData() {
        webView.loadUrl(url);
        webTitle.setText(title);

        WebSettings settings = webView.getSettings();
        //设置是否能识别js语言
        settings.setJavaScriptEnabled(true);
        webBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
